package com.anolesoft.amljmes.delivery.mapper;

import java.util.List;

import com.anolesoft.amljmes.delivery.deliwebservice.dto.MesBzzScjljhDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;

import com.anolesoft.amljmes.delivery.dto.MesScjljhDto;
import org.apache.ibatis.annotations.Select;

/**
 * 
 * @author 王佳明
 * @date 2022/4/28
 *
 */
@Mapper
public interface MesScjljhMapper {

	//条件查询
	List<MesScjljhDto> queryScjljh(MesScjljhDto dto);
	
	//修改可用状态
	Integer updateScjljh(MesScjljhDto dto);
	
	//生成计量计划
	@Insert("insert into mes_bzz_fcfhjh\n" +
			"  (qualified_label_number,\n" +
			"   expiration_time,\n" +
			"   plan_type,\n" +
			"   jixing,\n" +
			"   tuhao,\n" +
			"   paigonghao,\n" +
			"   jiaofuchejian,\n" +
			"   jieshouchejian,\n" +
			"   jiaofushunxu,\n" +
			"   shuliang,\n" +
			"   c_user," +
			"	c_time)\n" +
			"values\n" +
			"  (#{hegebiaoqian},\n" +
			"   to_date(#{jlq}, 'yyyy/MM/dd'),\n" +
			"   2,\n" +
			"   #{jixing},\n" +
			"   #{tuhao},\n" +
			"   #{paigonghao},\n" +
			"   #{jiaofuchejian},\n" +
			"   #{jieshouchejian},\n" +
			"   #{jiaofushunxu},\n" +
			"   #{zaikushuliang},\n" +
			"   #{xiugairen}," +
			"	sysdate)")
	Integer insertScjljh(MesBzzScjljhDto dto);
	
	//主键查询
	MesScjljhDto queryScjljhByObjuid(MesScjljhDto dto);

	/**
	 * 判断封存防护计划表中是否已经生成计量计划了   如果等于1将合格标签取出   传回前台
	 */
	@Select("select count(t.objuid) from mes_bzz_fcfhjh t where t.qualified_label_number = #{hgbq} and t.plan_type = '2' and t.state != '3' ")
	int countfcfh(String hgbq);
}
